<?php
    $page_title = 'สถาบันภาษา BV Language : Hall of Fame';
    include('header.php');
     // PAGE LIMIT
    if(isset($_GET['p'])){
	$page = $_GET['p'];
    }else{
	$page = 1;
    }
    
    $sql_relate = "SELECT * FROM hall_of_fame WHERE hof_active=1 ORDER BY hof_id DESC";
    
    $page_limit = 10;
    $start_row = (($page-1))*$page_limit;
    $sql_relate_nolimit = $sql_relate;
    $sql_relate .= " LIMIT $start_row,$page_limit";
    // PAGE LIMIT END

    // PAGE LIMIT
    $count_row = $db->Execute($sql_relate_nolimit);
    $count_row2 = $count_row->NumRows();
    $count_row3 = ceil($count_row2/$page_limit) ;
    
    //echo $count_row3;
    
    $limitlinkNext = '&nbsp;';
    $limitlinkPrev = '&nbsp;';
    if($count_row3>1)
    {
	if($page==1){
	    $limitlinkNext = '<a href="hall_of_fame.php?p=2">หน้าถัดไป >>></a>';
	}else if($page==$count_row3){
	    $limitlinkPrev = '<a href="hall_of_fame.php?p='.($page-1).'"><<< หน้าที่แล้ว</a>';
	}else{
	    $limitlinkNext = '<a href="hall_of_fame.php?p='.($page+1).'">หน้าถัดไป >>></a>';
	    $limitlinkPrev = '<a href="hall_of_fame.php?p='.($page-1).'"><<< หน้าที่แล้ว</a>';
	}
    }
    
    //echo $limitlink;
    
    $result = $db->Execute($sql_relate);
    $news_list = '';
    $news_list2 = '';
    $i = 1;
    while (!$result->EOF)
    {
	if(file_exists($iniVars['Locations']['sitepath'].$result->fields['hof_img']) AND ($result->fields['hof_img']!=NULL AND $result->fields['hof_img']!=''))
	{
	    $news_img = $iniVars['Locations']['siteurl'].$result->fields['hof_img'];
	}
	else
	{
	    $news_img = $iniVars['Locations']['siteurl'].'images/bvk_logo.jpg';
	}
	
	if($i==1){
	    $imgFirst = '<img src="'.$news_img.'" alt="'.$result->fields['hof_name'].'" />';
	    $msgFirst = '"'.$result->fields['hof_msg'].'"';
	}
	
	if($i%2){
	    $news_list2Class = ' hall_of_fame_name_0';
	}else{
	    $news_list2Class = '';
	}
	
	$news_list .= <<<sdl
		<li><img class="hall_of_fame_slide_list_img" src="{$news_img}" alt="{$result->fields['hof_msg']}" /></li>
sdl;
	$news_list2 .= <<<sdl
		<tr>
		    <td class="hall_of_fame_flag">
			<img src="images/hall_of_fame/flag_{$result->fields['hof_lang']}.jpg" />
		    </td>
		    <td class="hall_of_fame_img">
			<img src="{$news_img}" />
		    </td>
		    <td class="hall_of_fame_name hall_of_fame_name_{$news_list2Class}">
			{$result->fields['hof_name']}
		    </td>
		    <td class="hall_of_fame_msg hall_of_fame_msg_{$news_list2Class}">
			{$result->fields['hof_msg']}
		    </td>
		</tr>
sdl;
	$i++;
	$result->MoveNext();
    }
    
    require_once('search.php');
?>
	    <script type="text/javascript" src="js/jcarousellite_1.0.1.min.js"></script>
	    <script type="text/javascript">
		jQuery(document).ready(function() {
		    jQuery('#hall_of_fame_slide_list').jCarouselLite({
			btnNext: "#hall_of_fame_slide_next img",
			btnPrev: "#hall_of_fame_slide_prev img",
			pause: true,
			auto: 2500,
			speed: 1500,
			visible : 7,
			afterEnd : function(a) {
			    var imgSource = a.find('img').attr('src');
			    var imgDescTh = a.find('img').attr('alt');
			    $('#hall_of_fame_slide_img').find('img').attr('src',imgSource)
			    $('#hall_of_fame_slide_msg').html('"'+nl2br(imgDescTh)+'"')
			}
		    });
		    
		    $('.hall_of_fame_slide_list_img').click(function(){
			var imgSource = $(this).attr('src');
			var imgDescTh = $(this).attr('alt');
			$('#hall_of_fame_slide_img').find('img').attr('src',imgSource)
			$('#hall_of_fame_slide_msg').html('"'+nl2br(imgDescTh)+'"')
		   });
		});
	    </script>
	    <div id="hall_of_fame" class="main_content">
                
		<div id="hall_of_fame_top">
		    <div id="hall_of_fame_title">
			<img src="images/hall_of_fame_title.jpg" alt="เสียงตอบกลับจากนักเรียน"/>
		    </div>
		    
		    <div id="hall_of_fame_slide">
			<div id="hall_of_fame_slide_left">
			    สถาบันภาษา <span class="text_color16">BV</span>&nbsp;<span class="text_color15">Language</span><br />
ขอขอบคุณนักเรียนทุกท่าน 
ที่เปิดโอกาส<br />ให้เราเป็นผู้ดึงอัจฉริยภาพทางภาษา<br />
และเป็นส่วนหนึ่งของความสำเร็จจากรุ่น<br />สู่รุ่น 
ขอขอบคุณจริงๆค่ะ			</div>
			<div id="hall_of_fame_slide_img">
			    <?php echo $imgFirst; ?>
			</div>
			<div id="hall_of_fame_slide_msg">
			    <?php echo $msgFirst; ?>
			</div>
			<div class="clear">&nbsp;</div>
			
			<div id="hall_of_fame_slide_prev">
			    <img src="images/hall_of_fame_slide_prev.jpg" class="img_link" />
			</div>
			<div id="hall_of_fame_slide_list">
			    <ul>
				<?php echo $news_list; ?>
			    </ul>
			</div>
			<div id="hall_of_fame_slide_next">
			    <img src="images/hall_of_fame_slide_next.jpg" class="img_link" />
			</div>
			<div class="clear">&nbsp;</div>
		    </div>
		    
		    <table id="hall_of_fame_tb">
			<tr>
			    <td class="hall_of_fame_flag">&nbsp;</td>
			    <td class="hall_of_fame_img hall_of_fame_img_title">&nbsp;</td>
			    <td class="hall_of_fame_name hall_of_fame_name_title">ชื่อ</td>
			    <td class="hall_of_fame_msg hall_of_fame_msg_title">ความสำเร็จจากการเรียนภาษาที่ <span class="text_color16">BV</span>&nbsp;<span class="text_color15">Language</span></td>
			</tr>
			<?php echo $news_list2; ?>
		    </table>
		    
		    <div id="hall_of_fame_prev">
			<?php echo $limitlinkPrev; ?>
		    </div>
		    <div id="hall_of_fame_next">
			<?php echo $limitlinkNext; ?>
		    </div>
		    <div class="clear">&nbsp;</div>
		</div>
		
            </div>
            <!-- class main_content -->
<?
    include('footer.php');
?>